package com.vincent.kdp.Activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.vincent.baseapp.util.CommonUtil;
import com.vincent.kdp.R;
import com.vincent.kdp.adapter.CraftAdapter;
import com.vincent.kdp.adapter.MetalColorAdapter;
import com.vincent.kdp.adapter.MySeriesGridViewAdapter;
import com.vincent.kdp.adapter.QualityGridViewAdapter;
import com.vincent.kdp.adapter.SeriesAdapter;
import com.vincent.kdp.bean.MyCraftBean;
import com.vincent.kdp.bean.MyMetalColorBean;
import com.vincent.kdp.bean.MySeriesAdapterBean;
import com.vincent.kdp.bean.QualityBean;
import com.vincent.kdp.contract.SelectContract;
import com.vincent.kdp.http.RequestCallBack;
import com.vincent.kdp.presenter.SelectPresenter;
import com.vincent.kdp.ui.bean.response.CommodityListOut;
import com.vincent.kdp.ui.commodity.CommodityListActivity;
import com.vincent.kdp.ui.fragment.repository.CommodityRepository;
import com.vincent.kdp.view.NoScrollGridView;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SelectSearchActivity extends Activity implements SelectContract.View {
    @Bind(R.id.search)
    RelativeLayout search;
    @Bind(R.id.select_caiZhi)
    TextView select_caiZhi;
    @Bind(R.id.select_all_caiZhi)
    NoScrollGridView selectAllCaiZhi;
    @Bind(R.id.select_style)
    TextView selectStyle;
    @Bind(R.id.gridView_style)
    NoScrollGridView gridViewStyle;
    @Bind(R.id.myseries)
    NoScrollGridView myseries;
    @Bind(R.id.select_series)
    TextView selectSeries;
    @Bind(R.id.select_craft)
    TextView selectCraft;
    @Bind(R.id.gridView_craft)
    NoScrollGridView gridView_craft;
    @Bind(R.id.select_metal_color)
    TextView selectMetalColor;
    @Bind(R.id.gridView_metal_color)
    NoScrollGridView gridView_metal_color;
    @Bind(R.id.select_click)
    TextView selectClick;
    @Bind(R.id.priceLow)
    EditText mPriceLow;
    @Bind(R.id.priceHigh)
    EditText mPriceHigh;
    @Bind(R.id.kgLow)
    EditText mKgLow;
    @Bind(R.id.kgHigh)
    EditText mKgHigh;

    @Bind(R.id.select_number)
    EditText mSelectNumber;
    @Bind(R.id.lin_priceLow)
    LinearLayout linPriceLow;
    @Bind(R.id.lin_kgLow)
    LinearLayout linKgLow;
    @Bind(R.id.company_style_num)
    EditText companyStyleNum;
    @Bind(R.id.lin_company_style_num)
    LinearLayout linCompanyStyleNum;
    @Bind(R.id.letterable)
    EditText letterable;
    @Bind(R.id.lin_letterable)
    LinearLayout linLetterable;

    @Bind(R.id.lin_craft)
    LinearLayout linCraft;

    @Bind(R.id.lin_metal_color)
    LinearLayout linMetalColor;

    @Bind(R.id.lin_chain_length)
    LinearLayout linChainLength;

    @Bind(R.id.lin_handLow)
    LinearLayout linHandLow;

    @Bind(R.id.strChainLength)
    EditText strChainLength;
    @Bind(R.id.endChainLength)
    EditText endChainLength;

    SelectContract.Presenter prsenter;
    //材质适配器
    QualityGridViewAdapter adapterQuality;
    //款式
    SeriesAdapter adapterSeries;
    //金属色
    MetalColorAdapter adapterMetal;
    //工艺
    CraftAdapter adapterCraft;
    //系列
    MySeriesGridViewAdapter adapterMySeries;
    //存储款式的集合
    ArrayList<QualityBean.QualityData.StyleListData> styleData = new ArrayList<>();
    //存储金属色的集合
    ArrayList<MyMetalColorBean.MyMetalColorData> metalColorData = new ArrayList<>();
    //存储工艺的集合
    ArrayList<MyCraftBean.MyCraftData> craftData = new ArrayList<>();
    @Bind(R.id.shoucunb)
    EditText shoucunb;
    @Bind(R.id.shoucunt)
    EditText shoucunt;
    //材质上次点击记录位置
    private int beforeQualityClick = 0;
    //款式上次点击记录位置
    private int beforeSeriesClick = 0;
    //工艺上次点击记录位置
    private int beforeCraftClick = 0;
    //金属色上次点击记录位置
    private int beforeMetalClick = 0;
    //系类上次点击记录位置
    private int beforeMySeriesClick = 0;
    //存储材质的id
    private String qualityId = null;
    //存储款式的id
    private String styleId = null;
    //存储金属色的id
    private String MetalColorId = null;
    //存储工艺的id
    private String CraftId = null;
    //选择系列的Id
    private String seriesId = null;

    private int visble = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_search);
        ButterKnife.bind(this);
        initData();
    }

    private void initData() {
        prsenter = new SelectPresenter(this);
        prsenter.reqSearch();
        prsenter.reqSeries();
    }

    @OnClick({R.id.search, R.id.select_caiZhi, R.id.select_style, R.id.select_craft, R.id.select_metal_color, R.id.select_series, R.id.select_click})
    public void lick(View view) {
        switch (view.getId()) {
            case R.id.search:
                finish();
                overridePendingTransition(com.vincent.baseapp.R.anim.fragment_left_in, com.vincent.baseapp.R.anim.fragment_right_out);
                break;
            case R.id.select_caiZhi:
                if (selectAllCaiZhi.getVisibility() == View.GONE) {
                    selectAllCaiZhi.setVisibility(View.VISIBLE);
                } else {
                    selectAllCaiZhi.setVisibility(View.GONE);
                }
                break;
            case R.id.select_style:
                if (gridViewStyle.getVisibility() == View.GONE) {
                    gridViewStyle.setVisibility(View.VISIBLE);
                } else {
                    gridViewStyle.setVisibility(View.GONE);
                }
                break;
            case R.id.select_craft:
                if (gridView_craft.getVisibility() == View.GONE) {
                    gridView_craft.setVisibility(View.VISIBLE);
                } else {
                    gridView_craft.setVisibility(View.GONE);
                }
                break;
            case R.id.select_metal_color:
                if (gridView_metal_color.getVisibility() == View.GONE) {
                    gridView_metal_color.setVisibility(View.VISIBLE);
                } else {
                    gridView_metal_color.setVisibility(View.GONE);
                }
                break;
            case R.id.select_series:
                if (myseries.getVisibility() == View.GONE) {
                    myseries.setVisibility(View.VISIBLE);
                } else {
                    myseries.setVisibility(View.GONE);
                }
                break;
            case R.id.select_click:

                /**
                 * 清除选择的条件
                 */
                /*if(qualityId!=null || styleId!=null || seriesId!=null){
                    adapterQuality.removeSelect();
                    adapterSeries.modifyColor();
                    adapterMySeries.removeMySeriesSelect();
                    styleData.clear();
                    adapterSeries.notifyDataSetChanged();
                    qualityId=null;
                    styleId=null;
                    seriesId=null;
                }*/

                //提交搜索条件
                submitSelect();
                break;
        }
    }

    @Override
    public void initSelectSearch(final ArrayList<QualityBean.QualityData> data) {
        adapterQuality = new QualityGridViewAdapter(this, data);
        selectAllCaiZhi.setAdapter(adapterQuality);
        //款式
        adapterSeries = new SeriesAdapter(this, styleData);
        gridViewStyle.setAdapter(adapterSeries);

        selectAllCaiZhi.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


                TextView tv1 = (TextView) selectAllCaiZhi.getChildAt(beforeQualityClick).findViewById(R.id.tv_quality);
                tv1.setTextColor(Color.parseColor("#311d0f"));
                GradientDrawable draw = new GradientDrawable();
                draw.setStroke(1, Color.parseColor("#ececec"));
                draw.setColor(Color.parseColor("#ffffff"));
                tv1.setBackground(draw);

                beforeQualityClick = position;
                TextView tv = (TextView) selectAllCaiZhi.getChildAt(position).findViewById(R.id.tv_quality);
                tv.setTextColor(Color.parseColor("#b79e2a"));
                GradientDrawable draw1 = new GradientDrawable();
                draw1.setColor(Color.parseColor("#ececec"));
                tv.setBackground(draw1);

                qualityId = data.get(position).getId() + "";
                select_caiZhi.setText("当前选择：" + data.get(position).getCategory());
                System.out.println("111111111111111111111111");
                prsenter.reqMetalColor(qualityId);
                System.out.println("122222222222");
                styleId = null;

                if (data.get(position).getStyleList().size() <= 0) {
                    Toast.makeText(SelectSearchActivity.this, "该材质暂无款式", Toast.LENGTH_SHORT).show();
                }
                adapterSeries.modifyColor();

                styleData.clear();
                styleData.addAll(data.get(position).getStyleList());
                adapterSeries.notifyDataSetChanged();

                beforeSeriesClick = 0;


                /**
                 * 搜索条件动态变化，显示与不显示
                 */
                //金重
                if (data.get(position).getSysCategoryMap().getNetGoldWeight() == 0) {
                    linKgLow.setVisibility(View.GONE);
                } else {
                    linKgLow.setVisibility(View.VISIBLE);
                }
                //价格
                if (data.get(position).getSysCategoryMap().getPrice() == 0) {
                    linPriceLow.setVisibility(View.GONE);
                } else {
                    linPriceLow.setVisibility(View.VISIBLE);
                }
                //公司款号
                if (data.get(position).getSysCategoryMap().getCompanyStyleNum() == 0) {
                    linCompanyStyleNum.setVisibility(View.GONE);
                } else {
                    linCompanyStyleNum.setVisibility(View.VISIBLE);
                }
                //刻字
                if (data.get(position).getSysCategoryMap().getLetterable() == 0) {
                    linLetterable.setVisibility(View.GONE);
                } else {
                    linLetterable.setVisibility(View.VISIBLE);
                }
                //工艺
                if (data.get(position).getSysCategoryMap().getCraft() == 0) {
                    linCraft.setVisibility(View.GONE);
                } else {
                    linCraft.setVisibility(View.VISIBLE);
                }
                //金属色
                if (data.get(position).getSysCategoryMap().getMetalColor() == 0) {
                    linMetalColor.setVisibility(View.GONE);
                } else {
                    linMetalColor.setVisibility(View.VISIBLE);
                }
                //链长
                if (data.get(position).getSysCategoryMap().getChainLength() == 0) {
                    linChainLength.setVisibility(View.GONE);
                    visble = 0;
                } else {
                    linChainLength.setVisibility(View.VISIBLE);
                    visble = 1;
                }

                //手寸
                if (data.get(position).getSysCategoryMap().getHandInch() == 0) {
                    linHandLow.setVisibility(View.GONE);
                } else {
                    linHandLow.setVisibility(View.VISIBLE);
                }
            }
        });

        gridViewStyle.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                TextView tv1 = (TextView) gridViewStyle.getChildAt(beforeSeriesClick).findViewById(R.id.tv_series);
                tv1.setTextColor(Color.parseColor("#311d0f"));
                GradientDrawable draw = new GradientDrawable();
                draw.setStroke(1, Color.parseColor("#ececec"));
                draw.setColor(Color.parseColor("#ffffff"));
                tv1.setBackground(draw);

                beforeSeriesClick = position;
                TextView tv = (TextView) gridViewStyle.getChildAt(position).findViewById(R.id.tv_series);
                tv.setTextColor(Color.parseColor("#b79e2a"));
                GradientDrawable draw1 = new GradientDrawable();
                draw1.setColor(Color.parseColor("#ececec"));
                tv.setBackground(draw1);

                styleId = styleData.get(position).getId();
                prsenter.reqCraft(qualityId, styleId);
                selectStyle.setText("当前选择：" + styleData.get(position).getName());


            }
        });
    }

    @Override
    public void initMetalColorSearch(final ArrayList<MyMetalColorBean.MyMetalColorData> data) {
        System.out.println("----MyMetalColorBean.MyMetalColorData---" + data.size());
        //金属色
        adapterMetal = new MetalColorAdapter(this, data);
        gridView_metal_color.setAdapter(adapterMetal);
        gridView_metal_color.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                TextView tv1 = (TextView) gridView_metal_color.getChildAt(beforeMetalClick).findViewById(R.id.tv_metalcolor);
                tv1.setTextColor(Color.parseColor("#311d0f"));
                GradientDrawable draw = new GradientDrawable();
                draw.setStroke(1, Color.parseColor("#ececec"));
                draw.setColor(Color.parseColor("#ffffff"));
                tv1.setBackground(draw);


                beforeMetalClick = position;
                TextView tv = (TextView) gridView_metal_color.getChildAt(position).findViewById(R.id.tv_metalcolor);
                tv.setTextColor(Color.parseColor("#b79e2a"));

                GradientDrawable draw1 = new GradientDrawable();
                draw1.setColor(Color.parseColor("#ececec"));
                tv.setBackground(draw1);


                MetalColorId = data.get(position).getDictId() + "";
                selectMetalColor.setText("当前选择：" + data.get(position).getName());

            }
        });

    }

    @Override
    public void initCraftSearch(final ArrayList<MyCraftBean.MyCraftData> data) {
        System.out.println("----MyCraftBean.MyCraftDataa---" + data.size());
        //工艺
        adapterCraft = new CraftAdapter(this, data);
        gridView_craft.setAdapter(adapterCraft);
        gridView_craft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                TextView tv1 = (TextView) gridView_craft.getChildAt(beforeCraftClick).findViewById(R.id.tv_craft);
                tv1.setTextColor(Color.parseColor("#311d0f"));
                GradientDrawable draw = new GradientDrawable();
                draw.setStroke(1, Color.parseColor("#ececec"));
                draw.setColor(Color.parseColor("#ffffff"));
                tv1.setBackground(draw);


                beforeCraftClick = position;
                TextView tv = (TextView) gridView_craft.getChildAt(position).findViewById(R.id.tv_craft);
                tv.setTextColor(Color.parseColor("#b79e2a"));

                GradientDrawable draw1 = new GradientDrawable();
                draw1.setColor(Color.parseColor("#ececec"));
                tv.setBackground(draw1);


                CraftId = data.get(position).getDictId() + "";
                selectCraft.setText("当前选择：" + data.get(position).getName());

            }
        });

    }


    @Override
    public void initSeriesSearch(final ArrayList<MySeriesAdapterBean.MySeriesData> data) {


        adapterMySeries = new MySeriesGridViewAdapter(this, data);

        myseries.setAdapter(adapterMySeries);

        myseries.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                TextView tv1 = (TextView) myseries.getChildAt(beforeMySeriesClick).findViewById(R.id.tv_series);
                tv1.setTextColor(Color.parseColor("#311d0f"));
                GradientDrawable draw = new GradientDrawable();
                draw.setStroke(1, Color.parseColor("#ececec"));
                draw.setColor(Color.parseColor("#ffffff"));
                tv1.setBackground(draw);


                beforeMySeriesClick = position;
                TextView tv = (TextView) myseries.getChildAt(position).findViewById(R.id.tv_series);
                tv.setTextColor(Color.parseColor("#b79e2a"));

                GradientDrawable draw1 = new GradientDrawable();
                draw1.setColor(Color.parseColor("#ececec"));
                tv.setBackground(draw1);


                seriesId = data.get(position).getDictId() + "";
                selectSeries.setText("当前选择：" + data.get(position).getName());

            }
        });
    }

    CommodityRepository mCommodityRepository = new CommodityRepository();

    private void submitSelect() {

        String slpriceLow = mPriceLow.getText().toString().trim();
        String slpriceHigh = mPriceHigh.getText().toString().trim();

        String slkgLow = mKgLow.getText().toString().trim();
        String slkgHigh = mKgHigh.getText().toString().trim();

        String slgirard = companyStyleNum.getText().toString().trim();
        //手寸
        String slhandLow = shoucunb.getText().toString().trim();
        System.out.println("slhandLow----1111" + slhandLow);
        String slhandHigh = shoucunt.getText().toString().trim();
        System.out.println("slhandHigh----11111" + slhandHigh);

        String ChainLengthLow = strChainLength.getText().toString().trim();
        String ChainLengthHigh = endChainLength.getText().toString().trim();


        String slbarcode = mSelectNumber.getText().toString().trim();

        if (!(TextUtils.isEmpty(slpriceLow) && TextUtils.isEmpty(slpriceHigh))) {
            if (TextUtils.isEmpty(slpriceLow) || TextUtils.isEmpty(slpriceHigh)) {
                Toast.makeText(this, "请输入价格区间", Toast.LENGTH_SHORT).show();
                return;
            }
            if (Double.parseDouble(slpriceLow) > Double.parseDouble(slpriceHigh)) {
                Toast.makeText(this, "价格区间从低到高", Toast.LENGTH_SHORT).show();
                return;
            }
        }
        if (!(TextUtils.isEmpty(slkgLow) && TextUtils.isEmpty(slkgHigh))) {
            if (TextUtils.isEmpty(slkgLow) || TextUtils.isEmpty(slkgHigh)) {
                Toast.makeText(this, "请输入克重区间", Toast.LENGTH_SHORT).show();
                return;
            }
            if (Double.parseDouble(slkgLow) > Double.parseDouble(slkgHigh)) {
                Toast.makeText(this, "克重区间从低到高", Toast.LENGTH_SHORT).show();
                return;
            }
        }

        if (!(TextUtils.isEmpty(slhandLow) && TextUtils.isEmpty(slhandHigh))) {
            if (TextUtils.isEmpty(slhandLow) || TextUtils.isEmpty(slhandHigh)) {
                System.out.println("slhandLow----eeee" + slhandLow);
                System.out.println("slhandHigh----eee" + slhandHigh);
                Toast.makeText(this, "请输入手寸区间", Toast.LENGTH_SHORT).show();
                return;
            }
            if (Double.parseDouble(slhandLow) > Double.parseDouble(slhandHigh)) {
                System.out.println("slhandLow----eeee" + slhandLow);
                System.out.println("slhandHigh----eee" + slhandHigh);
                Toast.makeText(this, "手寸区间从低到高", Toast.LENGTH_SHORT).show();
                return;
            }
        }

        if (visble == 1) {
            if (!(TextUtils.isEmpty(ChainLengthLow) && TextUtils.isEmpty(ChainLengthHigh))) {
                if (TextUtils.isEmpty(ChainLengthLow) || TextUtils.isEmpty(ChainLengthHigh)) {
                    Toast.makeText(this, "请输入链长区间", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (Double.parseDouble(ChainLengthLow) > Double.parseDouble(ChainLengthHigh)) {
                    Toast.makeText(this, "链长区间从低到高", Toast.LENGTH_SHORT).show();
                    return;
                }
            }
        }

        if (TextUtils.isEmpty(slpriceLow)) {
            slpriceLow = null;
        }
        if (TextUtils.isEmpty(slpriceHigh)) {
            slpriceHigh = null;
        }
        if (TextUtils.isEmpty(slkgLow)) {
            slkgLow = null;
        }
        if (TextUtils.isEmpty(slkgHigh)) {
            slkgHigh = null;
        }
        if (TextUtils.isEmpty(slgirard)) {
            slgirard = null;
        }
        if (TextUtils.isEmpty(slhandLow)) {
            System.out.println("22222222222222222");
            slhandLow = null;
        }
        if (TextUtils.isEmpty(slhandHigh)) {
            System.out.println("22222222222222222");
            slhandHigh = null;
        }
        if (TextUtils.isEmpty(ChainLengthLow)) {
            ChainLengthLow = null;
        }
        if (TextUtils.isEmpty(ChainLengthHigh)) {
            ChainLengthHigh = null;
        }
        if (TextUtils.isEmpty(slbarcode)) {
            slbarcode = null;
        }
        Log.i("code", "材质：" + qualityId + "\n--高价格--" + slpriceLow + "\n--低价格--" + slpriceHigh + "\n--低克重--" + slkgLow + "\n--高克重--" + slkgHigh +
                "\n-款式--" + styleId + "\n--系列--" + seriesId + "\n--款号--" + slgirard + "\n--高手寸--" + slhandLow + "\n--低手寸--" + slhandHigh + "\n--条形码--" + slbarcode);

        System.out.println("slhandLow----lllll" + slhandLow);
        System.out.println("slhandHigh----lllll" + slhandHigh);

        if (qualityId == null && slpriceLow == null && slpriceHigh == null &&
                slkgLow == null && slkgHigh == null && styleId == null && seriesId == null && slgirard == null
                && slhandLow == null && slhandHigh == null && slbarcode == null) {
            Log.i("code", "材质：" + qualityId + "\n--高价格--" + slpriceLow + "\n--低价格--" + slpriceHigh + "\n--低克重--" + slkgLow + "\n--高克重--" + slkgHigh +
                    "\n-款式--" + styleId + "\n--系列--" + seriesId + "\n--款号--" + slgirard + "\n--高手寸--" + slhandLow + "\n--低手寸--" + slhandHigh + "\n--条形码--" + slbarcode);
            System.out.println("slhandLow----mmmmm" + slhandLow);
            System.out.println("slhandHigh----mmmmmm" + slhandHigh);
            Toast.makeText(this, "请至少输入一个查询条件", Toast.LENGTH_SHORT).show();
            return;
        }
        CommonUtil.showLoadingView(this);

        final String finalSlpriceLow = slpriceLow;
        final String finalSlpriceHigh = slpriceHigh;
        final String finalSlkgLow = slkgLow;
        final String finalSlkgHigh = slkgHigh;
        final String finalSlgirard = slgirard;
        final String finalSlhandLow = slhandLow;
        final String finalSlhandHigh = slhandHigh;
        final String finalSlbarcode = slbarcode;
        final String finalMetalColorId = MetalColorId;
        final String finalCraftId = CraftId;
        final String finChainLengthLow = ChainLengthLow;
        final String finChainLengthHigh = ChainLengthHigh;


        System.out.println("slhandLow----ffff" + slhandLow);
        System.out.println("slhandHigh----fffff" + slhandHigh);
        mCommodityRepository.reqSearchGoodsList(1, qualityId, slpriceLow, slpriceHigh, slkgLow, slkgHigh, styleId, seriesId,
                slgirard, slhandLow, slhandHigh, slbarcode,
                MetalColorId,
                CraftId,
                ChainLengthLow,
                ChainLengthHigh,
                new RequestCallBack() {
                    @Override
                    public void onSuccess(Object object) {
                        CommodityListOut bean = (CommodityListOut) object;
                        if (bean.getData().getList().size() <= 0) {
                            Toast.makeText(SelectSearchActivity.this, "未搜索到数据", Toast.LENGTH_SHORT).show();
                        } else {
                            Intent intent = new Intent(SelectSearchActivity.this, CommodityListActivity.class);
                            intent.putExtra("qualityId", qualityId);
                            intent.putExtra("slpriceLow", finalSlpriceLow);
                            intent.putExtra("slpriceHigh", finalSlpriceHigh);
                            intent.putExtra("slkgLow", finalSlkgLow);
                            intent.putExtra("slkgHigh", finalSlkgHigh);
                            intent.putExtra("styleId", styleId);
                            intent.putExtra("seriesId", seriesId);
                            intent.putExtra("slgirard", finalSlgirard);
                            intent.putExtra("slhandLow", finalSlhandLow);
                            intent.putExtra("slhandHigh", finalSlhandHigh);
                            intent.putExtra("slbarcode", finalSlbarcode);
                            intent.putExtra("metalColor", finalMetalColorId);
                            intent.putExtra("craft", finalCraftId);
                            intent.putExtra("strChainLength", finChainLengthLow);
                            intent.putExtra("endChainLength", finChainLengthHigh);
                            intent.putExtra("from", "search");
                            startActivity(intent);
                            finish();
                        }
                        CommonUtil.dismissLoadingView(SelectSearchActivity.this);
                    }

                    @Override
                    public void onFalse(String msg) {
                        Toast.makeText(SelectSearchActivity.this, msg, Toast.LENGTH_SHORT).show();
                        CommonUtil.dismissLoadingView(SelectSearchActivity.this);
                    }
                });

    }


}
